import React from 'react'
import { render } from 'react-dom'

import './static/css/common.less'
// import Hello from "./containers/Hello/index"

class Root extends React.Component {
    constructor(props,context){
        super(props,context)
        this.state = {
            bg : ''
        }
    }
    render() {
        const arr = [
            {name:'张三'},
            {name:'李四'},
            {name:'王五'},
        ]
        return (
            <div>
               {
                   arr.map((data,index)=>{
                       return <li key={index} className={this.state.bg === index ? 'bg' : null} onClick=
                       {this.clickHandle.bind(this,index)}>{data.name}</li>
                   })
               }
            </div>
        )
    }

    clickHandle(index){
        this.setState({
            bg : index
        })
    }
}

render(
    <Root/>,
    document.getElementById('root')
)
